﻿Imports NMock2

Imports System.Collections.Generic
Imports Microsoft.VisualStudio.TestTools.UnitTesting

Imports Meiners.Libs.Withings
Imports Meiners.Libs.Withings.Core


Namespace Core

    '''<summary>
    '''This is a test class for HelperTest and is intended
    '''to contain all HelperTest Unit Tests
    '''</summary>
    <TestClass()> _
    Public Class HelperTest


        Private testContextInstance As TestContext

        '''<summary>
        '''Gets or sets the test context which provides
        '''information about and functionality for the current test run.
        '''</summary>
        Public Property TestContext() As TestContext
            Get
                Return testContextInstance
            End Get
            Set(ByVal value As TestContext)
                testContextInstance = value
            End Set
        End Property


        '''<summary>
        '''A test for EPOCHToDateTime
        '''</summary>
        <TestMethod()> _
        Public Sub EPOCHToDateTimeTest()
            Dim value As Integer = 0
            Dim expected As DateTime = New DateTime(1970, 1, 1, 0, 0, 0)
            Dim actual As DateTime
            actual = Helper.EPOCHToDateTime(value)
            Assert.AreEqual(Of DateTime)(expected, actual)
        End Sub

        '''<summary>
        '''A test for DateTimeToEPOCH
        '''</summary>
        <TestMethod()> _
        Public Sub DateTimeToEPOCHTest()
            Dim value As DateTime = New DateTime(1970, 1, 1, 0, 0, 0)
            Dim expected As Integer = 0
            Dim actual As Integer
            actual = Helper.DateTimeToEPOCH(value)
            Assert.AreEqual(Of Integer)(expected, actual)
        End Sub

        '''<summary>
        '''A test for ConvertToUTF8String
        '''</summary>
        <TestMethod()> _
        Public Sub ConvertToUTF8StringTest()
            Dim input As String = "bärig"
            Dim expected As String = "bÃ¤rig"
            Dim actual As String
            actual = Helper.ConvertToUTF8String(input)
            Assert.AreEqual(expected, actual)
        End Sub

        '''<summary>
        '''A test for UrlEncode
        '''</summary>
        <TestMethod()> _
        Public Sub EscapeUriStringTest()
            Dim input As String = "Your Own Application Description"
            Dim expected As String = "Your%20Own%20Application%20Description"
            Dim actual As String
            actual = Helper.EscapeUriString(input)
            Assert.AreEqual(expected, actual)
        End Sub

        '''<summary>
        '''A test for UrlEncode
        '''</summary>
        <TestMethod()> _
        Public Sub URLEncodeTest()
            Dim input As String = "http://www.yourdomain.net/yourCustomApplication.php"
            Dim expected As String = "http%3a%2f%2fwww.yourdomain.net%2fyourCustomApplication.php"
            Dim actual As String
            actual = Helper.UrlEncode(input)
            Assert.AreEqual(expected, actual)
        End Sub

    End Class

End Namespace